# coding:utf8
import os
from .make_driver import driver
from log import logger
import time


class Coaa:
    def __init__(self, driver):
        self.driver = driver
        
        pass
    
    
    def get_windows_img(self):
        filepath = os.path.dirname(os.path.abspath('.')) + '/screenshots/'
        rq = time.strftime('%Y%m%d%H%M', time.localtime(time.time()))
        screen_name = filepath + rq + '.png'
        try:
            self.driver.get_screenshot_as_file(screen_name)
            logger.debug("Had take screenshot and save to folder:/screenshots")
        except NameError:
            logger.debug("Failed to take screenshot! ??%s"%e)
            self.get_windows_img()
            
    

def find_element(self, *selector)
    try:
        element = self.driver.find_element(*selector)
        logger.debug("The Such ElementExpection:%s" % (selector))
        return
    except NoSuchElementException:
        element = self.driver.find_element()
